import 'package:flutter/material.dart';
import 'package:homepad/iot/basic_types.dart';
import 'package:homepad/styles.dart';

class AirConditionerModeView extends StatelessWidget {
  final ValueChanged<AirConditionerSystemMode>? onChanged;
  final AirConditionerSystemMode current;

  const AirConditionerModeView({super.key, this.onChanged, required this.current});

  final height = 328.0;
  final width = 172.0;

  @override
  Widget build(BuildContext context) {
    final MyStyles styles = Theme.of(context).extension<MyStyles>()!;
    final items = AirConditionerSystemMode.values.reversed.toList();
    return Container(
        width: width,
        height: height + 2,
        decoration: BoxDecoration(
            borderRadius: styles.radius, border: styles.border, color: Colors.white10),
        child: ClipRRect(
          borderRadius: styles.radius,
          child: Column(
            children: items.map<Widget>((item) {
              return GestureDetector(
                onTap: () {
                  onChanged?.call(item);
                },
                child: Container(
                  height: (height - items.length + 1) / items.length,
                  alignment: Alignment.center,
                  margin: EdgeInsets.only(bottom: item != items.last ? 1 : 0),
                  // todo 需要为不同的模式设置不同的颜色
                  color: item == current ? Colors.white : Colors.white10,
                  child: Text(item.name,
                      style: styles.textStyle
                          .copyWith(color: item == current ? Colors.black : Colors.white)),
                ),
              );
            }).toList(),
          ),
        ));
  }
}
